package lab.gene.action;

import java.util.Date;
import java.util.List;

import lab.gene.pojo.GeneImageFile;
import lab.gene.pojo.GeneSecondStagePCR;
import lab.gene.service.impl.GeneImageFileServiceImpl;
import lab.gene.service.impl.GeneSecondStagePCRServiceImpl;

import com.opensymphony.xwork2.ActionSupport;

public class ViewGeneSecondStagePCRAction extends ActionSupport {
	
	private static final long serialVersionUID = 1L;
	private List<GeneImageFile> imageList = null;
	private Date recordDate = null;
	private Integer ml1;
	private Integer ml2;
	private Integer volume1;
	private Integer volume2;
	private String comments = null;
	private String geneName = null;
	private String stepType = null;
	
	public String execute() {
		System.out.println("View Gene Second Stage PCR Action!");
		System.out.println(stepType);
		String result = "successC";
		GeneSecondStagePCRServiceImpl service = new GeneSecondStagePCRServiceImpl();
		GeneSecondStagePCR pcr = service.getGeneSecondStagePCR(geneName, stepType);
		if(pcr != null) {
			recordDate = pcr.getRecordDate();
			comments = pcr.getComments();
			ml1 = pcr.getMl1();
			ml2 = pcr.getMl2();
			volume1 = pcr.getVolume1();
			volume2 = pcr.getVolume2();
		}
		String formName = null;
		GeneImageFileServiceImpl fService = new GeneImageFileServiceImpl();	
		
		switch(stepType) {
		case "C":
			formName = "Second Stage PCR (C)";
			setImageList(fService.getGeneImageFilesByGeneNameAndFormName(geneName, formName));
			result = "successC";break;
		case "D":
			formName = "Second Stage PCR (D)";
			setImageList(fService.getGeneImageFilesByGeneNameAndFormName(geneName, formName));
			result = "successD";break;
		}
		return result;
	}

	public Date getRecordDate() {
		return recordDate;
	}

	public void setRecordDate(Date recordDate) {
		this.recordDate = recordDate;
	}

	public Integer getMl1() {
		return ml1;
	}

	public void setMl1(Integer ml1) {
		this.ml1 = ml1;
	}

	public Integer getMl2() {
		return ml2;
	}

	public void setMl2(Integer ml2) {
		this.ml2 = ml2;
	}

	public Integer getVolume1() {
		return volume1;
	}

	public void setVolume1(Integer volume1) {
		this.volume1 = volume1;
	}

	public Integer getVolume2() {
		return volume2;
	}

	public void setVolume2(Integer volume2) {
		this.volume2 = volume2;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	public String getGeneName() {
		return geneName;
	}

	public void setGeneName(String geneName) {
		this.geneName = geneName;
	}

	public String getStepType() {
		return stepType;
	}

	public void setStepType(String stepType) {
		this.stepType = stepType;
	}

	public List<GeneImageFile> getImageList() {
		return imageList;
	}

	public void setImageList(List<GeneImageFile> imageList) {
		this.imageList = imageList;
	}

}
